<?php 
class pager
{
   /**
     * 系统后台的分页
     * 不需要传条件分页  
     * 后添加前台翻页函数
     * @param int    $pagecount 多少页
     * @param int    $page   当前第几页
     * @param string $table_style
     * @param string $font_style
     * @param int    $result_num       总条数
     * @param int    $page_size         该页显示的数量
     */
    function outputadmin($pagecount, $page, $table_style, $font_style, $result_num, $page_size){
        @$action        = $_SERVER['REDIRECT_URL'];
        $pagetable     = "";
        $pagecountlist = "";
        $temp          = "";                                       
        if(isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])){
        $query = explode("&",$_SERVER['QUERY_STRING']);
            while(list($index, $value) = each($query)) {
                $a = explode("=",$value);
                if(strcmp(strtolower($a[0]),"page")!=0){
                    $temp .= $a[0]."=".$a[1]."&";
                }
            }
        }else{
            $temp = "";
        }
        if($pagecount > 1)
        {
			$pagetable .=  "<div class=\"modal-footer no-margin-top\">";
            $pagetable .="<span class=\"pull-left no-margin hidden-xs\" style=\"padding:6px;\">共：".$result_num." 条/ ".$pagecount." 页</span>";
            $pagetable .="<ul class=\"pagination pull-right no-margin hidden-xs\">";
            if($page<=1){
                $pagetable .="<li class=\"disabled\"><a href=\"#\"><i class=\"ace-icon fa fa-angle-double-left\"></i></a></li>";
                $pagetable .= "<li class=\"disabled\"><a href=\"#\"><i class=\"ace-icon fa fa-angle-left\"></i></a></li>";
            }
            else{
				$pagetable .="<li><a href=".$action."?".$temp."page=1><i class=\"ace-icon fa fa-angle-double-left\"></i></a></li>";
                $pagetable .= "<li><a href=".$action."?".$temp."page=".($page-1)."><i class=\"ace-icon fa fa-angle-left\"></i></a></li>";
            }
            $start = 1;
            for($i=$start;$i<=$pagecount;$i++){
                $k=$page+5;
                $f=$page-4;
                if($page<=5 && $i<=10){
                    if($page == $i){
                        $pagecountlist .= "<li class=\"active\"><a href=\"#\">".$i."</a></li>";
                    }else{
                        $pagecountlist .= "<li><a href=".$action."?".$temp."page=".$i.">".$i."</a></li>";
                    }
                }elseif($k>=$pagecount && $i>($pagecount-10)){
                    if($page == $i){
                        $pagecountlist .= "<li class=\"active\"><a href=\"#\">".$i."</a></li>";
                    }else{
                        $pagecountlist .= "<li><a href=".$action."?".$temp."page=".$i.">".$i."</a></li>";
                    }
                }elseif($i>=$f && $i<=$k){
                    if($page == $i){
                        $pagecountlist .= "<li class=\"active\"><a href=\"#\">".$i."</a></li>";
                    }else{
                        $pagecountlist .= "<li><a href=".$action."?".$temp."page=".$i.">".$i."</a></li>";
                    }
                }
            }
			$pagetable .= $pagecountlist."";
			if($page>=$pagecount){
				$pagetable .= "<li class=\"disabled\"><a href=\"#\"><i class=\"ace-icon fa fa-angle-right\"></i></a></li>";
				$pagetable .= "<li class=\"disabled\"><a href=\"#\"><i class=\"ace-icon fa fa-angle-double-right\"></i></a></li>";
            }
            else{
				$pagetable .= "<li><a href=".$action."?".$temp."page=".($page+1)."><i class=\"ace-icon fa fa-angle-right\"></i></a></li>";
				$pagetable .= "<li><a href=".$action."?".$temp."page=".$pagecount."><i class=\"ace-icon fa fa-angle-double-right\"></i></a></li>";
			}
			$pagetable .="</ul>";
			
			$pagetable .="<div class=\"visible-xs\">";
				$pagetable .="<input type=\"text\" id=\"goToPage\" size=\"2\" maxlength=\"7\" value=".$page." style=\"width:55px;height:27px;\" lang=".$action."?".$temp." />";
				$pagetable .="&nbsp;&nbsp;<button class=\"btn btn-xs btn-danger\" id=\"pageGet\" style=\"margin-top:-2px;\">";//alert(window.location.href=".$action."?".$temp."page=document.getElementById(\"goToPage\").value)
				$pagetable .="GO<i class=\"ace-icon fa fa-arrow-circle-right icon-on-right\"></i></button>";
			
			$pagetable .="&nbsp;&nbsp;共：".$pagecount." 页</div>";
			$pagetable .=  "</div>";
        }
        
        return $pagetable;
    }
	
	
}